package gases.as3.librarys.components.factory
{
	import flash.utils.Dictionary;
	
	import gases.as3.librarys.components.events.LoadDataEvent;
	import gases.as3.librarys.components.swf.StyleConfig;

	public class DataManage
	{
		public function DataManage()
		{
			moduleViewDataDict = new Dictionary();
			config = StyleConfig.instance;
			config.addEventListener(LoadDataEvent.LOAD_MODULE_DATA_COMPLETE,fillData);
		}
		
		/**
		 *获得单例 
		 * @return DataManage
		 * 
		 */		
		public static function get instance():DataManage
		{
			if(!_instance)
			{
				_instance = new DataManage();
			}
			return _instance;
		}
	
		private function fillData(e:LoadDataEvent):void
		{
			var data:Dictionary = e.data as Dictionary;
			for(var key:String in data)
			{
				moduleViewDataDict[key] = data[key];
			}
		}
		/**
		 *通过ID获取相应的配置，id查询可以通过编译器查询 
		 * @param id
		 * @return 
		 * 
		 */		
		public function getViewConfigById(id:String):Array
		{
			var ret:Array = new Array();
			if(moduleViewDataDict[id])
			{
				ret = moduleViewDataDict[id] as Array;
			}
			return ret;
		}
		
		private static var _instance:DataManage;
		public var moduleViewDataDict:Dictionary;
		private var config:StyleConfig;
	}
}